package com.company.cloud.mall.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;

import com.company.cloud.common.bean.BaseClientResult;
import com.company.cloud.mall.modules.api.response.OrderModel;
import com.company.cloud.mall.modules.api.response.OrderRefundsModel;
import com.company.cloud.mall.modules.api.response.OrderReturnsModel;
import com.company.cloud.mall.modules.api.service.MallOrderRemoteService;
import com.company.cloud.mall.modules.app.service.ShopAfterSaleRefundsService;
import com.company.cloud.mall.modules.app.service.ShopAfterSaleReturnsService;
import com.company.cloud.mall.modules.app.service.ShopOrderService;

import lombok.extern.log4j.Log4j2;


@Log4j2
@RestController
@Service
public class MallOrderRemoteServiceImpl implements MallOrderRemoteService{
	

	@Autowired
	private ShopOrderService shopOrderService;
	@Autowired
	private ShopAfterSaleReturnsService shopAfterSaleReturnsService;
	@Autowired
	private ShopAfterSaleRefundsService shopAfterSaleRefundsService;

	@SuppressWarnings("unchecked")
	@Override
	public BaseClientResult<OrderModel> orderById(String sn) {
		try {
			OrderModel data= shopOrderService.getOrder(sn, false, false, false, false, true);
			return BaseClientResult.success(data);
		} catch (Exception e) {
			return BaseClientResult.error(e);
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public BaseClientResult<OrderRefundsModel> orderRefundsById(String sn) {
		try {
			OrderRefundsModel data=shopAfterSaleRefundsService.get(sn);
			return BaseClientResult.success(data);
		} catch (Exception e) {
			return BaseClientResult.error(e);
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public BaseClientResult<OrderReturnsModel> orderReturnsById(String sn) {
		try {
			OrderReturnsModel data=shopAfterSaleReturnsService.get(sn);
			return BaseClientResult.success(data);
		} catch (Exception e) {
			return BaseClientResult.error(e);
		}
	}
	
	
	
	
	
	

}
